<template>
	<view class="wrap">
		<view class="bgView"></view>
		<view class="successBox">
			<view class="successImg">
				<image src="https://wavestation.oss-cn-shenzhen.aliyuncs.com/upload/1722933529209927.png"
					mode="widthFix" />
			</view>
			<view class="successText">报名成功！</view>
		</view>
		<view class="activityBox">
			<actCell :item="ballInfo" :showMap="true" :goNext="2"></actCell>
			<view class="lineBox">- 进入圈子 了解更多 -</view>
			<view class="cirBox">
				<view class="cirlist"
					:style="'background-image: url(' + (teamInfo.Logo ? teamInfo.Logo : '') + ');background-size: cover;background-repeat:no-repeat;'"
					@click.stop="nav_to('/pages/together/cirDetail?id=' + teamInfo.ID)">
					<view class="cirinfobox">
						<image class="hdimg" :src="teamInfo.Logo ? teamInfo.Logo : ''" mode="aspectFill"></image>
						<view class="cirinfo">
							<view class="cirname">{{ teamInfo.TeamName ? $util.entitiesToUtf16(teamInfo.TeamName) : ''
								}}
							</view>
							<view class="cirrem hiddenText">{{ teamInfo.Tips ? $util.entitiesToUtf16(teamInfo.Tips) : ''
								}}
							</view>
						</view>
					</view>
					<view class="databox">
						<view class="datatltie">
							<view class="datanum">{{ temaHotValue }}</view>
							<view class="datatext">挥力值</view>
						</view>
						<view class="datatltie">
							<view class="datanum">{{ temaBrowserNum }}</view>
							<view class="datatext">浏览</view>
						</view>
						<view class="datatltie">
							<view class="datanum">{{ teamInfo.MemberNum }}</view>
							<view class="datatext">成员</view>
						</view>
					</view>

					<view class="blackshadow"></view>
				</view>
			</view>
			<view class="btnBox">
				<view class="orderBtn" @click.stop="goOrder()">查看订单</view>
				<!--  #ifdef MP-WEIXIN -->
				<view class="shareBtn">
					<button hover-class="none" open-type="share" class="item">
						分享活动
					</button>

				</view>
				<!-- #endif -->
			</view>
		</view>
	</view>
</template>

<script>
import actCell from '../../components/actCell/actCell.vue';
export default {
	components: {
		actCell,
		},
	data() {
		return {
			ball_ID: 0,
			ballInfo: {},
			isRead: true,
			longitude: '',
			latitude: '',
			BarTitle: '',
			Title: '',
			maxCount: 200,
			Note: '',
			sum: 0,
			imageList: [],
			teamInfo: {},
			user: {},
			ticketNum:0,
		};
	},
	computed: {
		temaBrowserNum(){
		if(this.teamInfo.BrowserNum > 99999999){
			return (this.teamInfo.BrowserNum / 100000000).toFixed(1)+'亿'
		}
		else if(this.teamInfo.BrowserNum > 9999){
			return (this.teamInfo.BrowserNum / 10000).toFixed(1)+'W'
		}else{
			return this.teamInfo.BrowserNum
		}
		},
		temaHotValue(){
		if(this.teamInfo.HotValue > 99999999){
        return (this.teamInfo.HotValue / 100000000).toFixed(1)+'亿'
      	}else if(this.teamInfo.HotValue > 9999){
			return (this.teamInfo.HotValue / 10000).toFixed(1)+'W'
		}else{
			return this.teamInfo.HotValue
		}
		},
	},
	async onLoad(e) {
		this.ball_ID = e.id;
		let loc = await this.getLocationSysc();
		this.getTicketNum()
		this.longitude = loc.longitude;
		this.latitude = loc.latitude;
		this.getDetail()

	},
	async onShow() {

	},
	methods: {
		// 获取票号
		async getTicketNum(){
			let res = await this.$api.post('Appointment/MySign', {
				AppointmentID: this.ball_ID
			});
			if (res.code == 0) {
				this.ticketNum = res.data?.ActionCode
			}

		},
		async getserve() {
			let title;
			if (this.ballInfo.AppointmentType == '一起挥') {
				title = '一起挥报名'
			} else if (this.ballInfo.AppointmentType == '找私教') {
				title = '找私教报名'
			} else {
				title = '招学员报名'
			}
			let res = await this.$api.post("Common/GetServerPrice", {
				Item: title,
			});
			if (res.code == 0) {
				this.sum = res.data.Score
			}
		},
		async getDetail() {
			this.user = uni.getStorageSync('user');
			let res = await this.$api.post('Appointment/Detail', {
				ID: this.ball_ID,
				User_Lng: this.longitude,
				User_Lat: this.latitude
			});
			if (res.code == 0) {
				this.ballInfo = res.data;
				this.imageList = res.data.Images.split(',')
				this.Note = this.repdis(res.data.Remark)
				this.getserve()
				this.cirDetail(res?.data?.TeamID || 0)
			}
		},
		//圈子详情
		async cirDetail(id = 0) {
			let cirID = id == 0 ? 1109 : id || 1109
			let res = await this.$api.post("Team/Detail", {
				ID: cirID
			})
			if (res.code == 0) {
				this.teamInfo = res.data
			}
		},
		//过滤标签
		repdis(msg) {
			var msg = msg.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
			msg = msg.replace(/[|]*\n/, ''); //去除行尾空格
			msg = msg.replace(/&npsp;/gi, ''); //去掉npsp
			return msg;
		},
		// 获取定位
		async getLocationSysc() {
			let _this = this;
			return new Promise((resolve, reject) => {
				uni.getLocation({
					type: 'gcj02',
					success: function (res) {
						resolve(res)
					},
					fail: function (err) {
						const defaultLocation = {
							latitude: 0,
							longitude: 0
						};
						resolve(defaultLocation);
					}
				});
			})

		},
		getTime2(l) {
			let d = new Date(l);
			let timestamp = d.getTime();
			return this.$u.date(timestamp, 'mm-dd');
		},
		getWeek(l) {
			let d = new Date(l);
			let week = d.getDay();
			let weelStr =
				week == 0 ?
					'星期天' :
					week == 1 ?
						'星期一' :
						week == 2 ?
							'星期二' :
							week == 3 ?
								'星期三' :
								week == 4 ?
									'星期四' :
									week == 5 ?
										'星期五' :
										'星期六';
			return weelStr;
		},
		// 跳转订单详情
		goOrder(){
			this.nav_to(`/pages/together/order_detail?id=${this.ticketNum}`)
		},
	},
	onShareAppMessage(res) {

		//发送给朋友
		var pid = this.user.UserID;
		return {
			title: this.$util.entitiesToUtf16(this.user.Name) + '邀请您加入',
			path: '/pages/ball/ball_details?pid=' + pid + '&id=' + this.ball_ID
		};

	},
};
</script>

<style lang="scss">
page {
	background-color: #f6f6f6;
}

button {
	padding: 0;
	margin: 0;
	border: none
}

button::after {
	border: none;
}

view {
	box-sizing: border-box;
}

.wrap {
	position: relative;

	.bgView {
		width: 100%;
		height: 336rpx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: -1;
		background-color: #706EEE;
	}

	.successBox {
		width: 100%;
		height: 162rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		.successImg {
			width: 32rpx;
			height: 32rpx;

			>image {
				width: 100%;
				height: 100%;
				display: block;
			}
		}

		.successText {
			font-weight: bold;
			font-size: 36rpx;
			color: #FFFFFF;
		}
	}
}

.activityBox {
	width: 100%;
	padding: 0 32rpx;

	
}


.lineBox {
	width: 100%;
	text-align: center;
	margin: 48rpx 0;
	font-weight: 500;
	font-size: 28rpx;
	color: #333333;
}

.Placebox {
	width: 100%;
	height: 150rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background-color: #fff;
	margin-top: 16rpx;

	.left {
		margin-left: 32rpx;
		display: flex;
		align-items: center;
		flex: 1;
		justify-content: space-between;

		.title {
			font-size: 32rpx;
			font-weight: 600;
			color: #333333;
		}

		.dis {
			font-size: 28rpx;
			font-weight: 500;
			color: #999999;
			margin-right: 24rpx;
		}
	}

	.mapimg {
		width: 56rpx;
		height: 56rpx;
		margin-right: 32rpx;
	}
}

.cirBox {
	width: 100%;

	.cirlist {
		width: 702rpx;
		// height: 548rpx;
		border-radius: 24rpx;
		padding: 36rpx 32rpx;
		// background-color: #9796ed;
		margin: 0 auto;
		margin-top: 24rpx;
		position: relative;

		.blackshadow {
			position: absolute;
			top: 0;
			left: 0;
			width: 702rpx;
			height: 100%;
			background: rgba(0, 0, 0, 0.6);
			border-radius: 24rpx;
			backdrop-filter: blur(10px);

		}

		.cirinfobox {
			display: flex;
			align-items: center;
			margin-bottom: 32rpx;
			position: relative;
			z-index: 10;

			.hdimg {
				width: 104rpx;
				height: 104rpx;
				// border-radius: 16rpx;
				border-radius: 50%;
				border: 4rpx solid #FFFFFF;
				margin-right: 24rpx;
			}

			.cirinfo {
				flex: 1;

				.cirname {
					font-size: 32rpx;
					font-weight: bold;
					color: #fff;
					margin-bottom: 16rpx;
				}

				.cirrem {
					width: 400rpx;
					font-size: 24rpx;
					color: #EFEFEF;
				}
			}

			.cirjoin {
				width: 120rpx;
				height: 56rpx;
				background: #6C6AFF;
				border-radius: 28rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				.joinimg {
					width: 24rpx;
					height: 24rpx;
				}

				.jointext {
					font-size: 24rpx;
					color: #EFEFEF;
				}
			}

			.cirquit {
				width: 120rpx;
				height: 56rpx;
				border-radius: 28rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #E4E4E4;

				.joinimg {
					width: 24rpx;
					height: 24rpx;
				}

				.jointext {
					font-size: 24rpx;
					color: #999999;
				}
			}
		}

		.databox {
			display: flex;
			align-items: center;
			position: relative;
			z-index: 10;

			.datatltie {
				margin-right: 56rpx;
				text-align: center;

				.datanum {
					font-size: 36rpx;
					font-weight: bold;
					color: #EFEFEF;
				}

				.datatext {
					font-size: 24rpx;
					color: #EFEFEF;
				}
			}
		}
	}
}

.btnBox {
	width: 100%;
	margin-top: 48rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;

	.orderBtn {
		width: 328rpx;
		height: 96rpx;
		border-radius: 48rpx;
		border: 2rpx solid #706EEE;
		font-weight: 500;
		font-size: 32rpx;
		color: #706EEE;
		display: flex;
		justify-content: center;
		align-items: center;
		/* #ifdef APP-PLUS */
		width: 100%;
		/* #endif */
	}

	.shareBtn {
		width: 328rpx;
		height: 96rpx;
		border-radius: 48rpx;
		border: 2rpx solid transparent;
		background: #706EEE;
		display: flex;
		justify-content: center;
		align-items: center;

		button {
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
		}
	}
}
</style>